


import Vue from 'vue'
import Router from 'vue-router'
import index from '@/views/index';

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

// 公共路由
export const constantRoutes =  [
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '',
            name: 'index',
            component: index,
            children: [
                 {
                      path: '/home',
                      name: 'home',
                      component: () => import('@/views/home'),
                }
              ]
        }

    ]
// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = [] 


// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
let routerReplace = Router.prototype.replace;
// push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'history', // 去掉url中的#
  base:'/dataShow/',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})


